package CSDN;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 王圆豪
 * Date: 2025-05-08
 * Time: 9:47
 */

public class Test16 {
    public static void main(String[] args) {
        Object locker1 = new Object();
        Thread t1 = new Thread(()->{
            synchronized (locker1) {
                System.out.println("线程t1wait......");
                try {
                    locker1.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("线程t1被唤醒！");
            }
        });
        Thread t2 = new Thread(()->{
            synchronized (locker1) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t2线程尝试唤醒t1......");
                locker1.notify();
            }
        });
        t1.start();
        t2.start();
    }
}
